import { defineStore } from 'pinia'
import { darkTheme } from 'naive-ui'
import type { ThemeStoreType } from '@/stores/interface'

const themeMap: Record<string, any> = {
  dark: darkTheme,
  light: null
}
export const useThemeStore = defineStore('theme', {
  persist: true,
  state: (): ThemeStoreType => {
    return {
      themeName: 'light'
    }
  },
  getters: {
    getCurrentTheme(): any {
      return themeMap[this.themeName]
    }
  },
  actions: {
    setDarkTheme() {
      this.themeName = 'dark'
    },
    setLightTheme() {
      this.themeName = 'light'
    }
  }
})
